/**
 * Copyright(c) 2013 Jade Techonologies Co., Ltd.
 *
 * History:
 *   13-4-14 下午3:58 Created by dwzhang
 */
package com.jade.framework.base.criterion.expression;

/**
 * Class for "property operation" comparisons (with SQL binary operators).
 * operation includes ==, <>, >, <, <=, >=。
 * <p/>
 * in order to support multi-table conjunction
 *
 * @author dwzhang
 * @version 1.0 13-4-14 下午3:58
 */
public class ConjunctionExpression extends AbstractPropertyExpression
{
    /** 操作类型 */
    private final String operation;
    /** 比较值 */
    private Object value;

    /**
     * 构造函数.
     *
     * @param entityName 实体名称
     * @param propName   属性名称。
     * @param value      比较值
     * @param operation  操作类型，包括==, <>, >, <, <=, >=等。
     */
    public ConjunctionExpression(String entityName, String propName, Object value, String operation)
    {
        super(entityName, propName);
        this.value = value;
        this.operation = operation;
    }

    /**
     * 构造函数.
     *
     * @param propName  属性名称。
     * @param value     比较值
     * @param operation 操作类型，包括==, <>, >, <, <=, >=等。
     */
    public ConjunctionExpression(String propName, Object value, String operation)
    {
        super(propName);
        this.value = value;
        this.operation = operation;
    }

    /**
     * 获取操作类型.
     *
     * @return 操作类型
     */
    public String getOperation()
    {
        return operation;
    }

    /**
     * 获取比较值.
     *
     * @return 比较值
     */
    public Object getValue()
    {
        return value;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append(getFullName()).append(operation).append(value);
        return sb.toString();
    }
}
